/**
 * Copyright (c) Daniel Centore
 *
 * ex: set filetype=java expandtab tabstop=4 shiftwidth=4 :
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * This code is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation.
 */
package ronp.anim.gui;

import java.awt.Frame;

import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import ronp.anim.data.filmstrip.Animation;
import ronp.anim.gui.viewer.AnimViewer;

public class OptionsDialog extends JDialog
{
	private static final long serialVersionUID = 1L;

	public OptionsDialog(final AnimViewer viewer, final Animation anim, final SelectedState state, Frame owner)
	{
		super(owner, true);
		this.setTitle("Options");
		this.setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

		final JSpinner spin = new JSpinner(new SpinnerNumberModel(anim.getFps(), 1, 1000, 1));
		spin.addChangeListener(new ChangeListener()
		{
			@Override
			public void stateChanged(ChangeEvent e)
			{
				int fps = (Integer) spin.getValue();
				anim.setFps(fps);
			}
		});


		JPanel fps = new JPanel();
		fps.add(new JLabel("FPS:"));
		fps.add(spin);
		this.add(fps);

		final JSpinner gripSpin = new JSpinner(new SpinnerNumberModel(10, 1, 1000, 1));
		gripSpin.addChangeListener(new ChangeListener()
		{
			@Override
			public void stateChanged(ChangeEvent e)
			{
				viewer.setGripSize((Integer) gripSpin.getValue());
				viewer.repaint();
			}
		});
		JPanel grip = new JPanel();
		grip.add(new JLabel("Grip Size:"));
		grip.add(gripSpin);
		this.add(grip);

		this.pack();
	}

}
